//
//  YMResponse.swift
//  ChengLuMall
//
//  Created by 吳梓杭 on 2023/6/1.
//

import Foundation
import SwiftyJSON

open class YMResponse {
    
    /// 最外层json
    var outsideJson: SwiftyJSON.JSON
    /// 字段data值
    var json: SwiftyJSON.JSON
    var code: Int?
    var message: String?
    
    init(json: SwiftyJSON.JSON?) {
        self.outsideJson = json ?? JSON()
        let dict = self.outsideJson.dictionaryObject
        if let dataObj = dict?["data"], !(dataObj is NSNull) {
            self.json = JSON(dataObj)
        } else {
            self.json = JSON()
        }
        self.code = dict?["code"] as? Int
        self.message = dict?["message"] as? String
    }
    
}
